package com.fbty.mt.action.admin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.fbty.base.action.BaseAction;
import com.fbty.base.domain.Page;
import com.fbty.mt.domain.OnlyIpInfo;
import com.fbty.mt.service.IpService;
import com.fbty.mt.service.OtherService;

@SuppressWarnings("serial")
public class OnlyAction extends BaseAction{
	
	private Page page;
	
	private IpService ipInfoService;
	
	private OtherService otherService;
	
	private String type="";
	
	private String country="";
	
	private String region="";
	
	private String city="";
	
	private String state;
	private int pageNo=1;
	
	private int pageSize=20;
	
	private boolean flag;
	private String ids;
	
	private int id;
	
	private double price;
	
	private String repeat;
	
	@SuppressWarnings({ "rawtypes", "unchecked" })
	public String execute(){
		Map parms=new HashMap();
		flag = repeat!=null&&"true".equals(repeat)?true:false;
		parms.put("region", "%"+region+"%");
		parms.put("type","".equals(type)?"%"+type+"%":type);
		parms.put("country", "%"+country+"%");
		parms.put("city", "%"+city+"%");
		page = ipInfoService.pageOnlyIpInsoes(pageNo, pageSize, flag, parms);
		return "success";
	}
	/**
	 * 批量删除共享类ip
	 * @return
	 * @throws Exception
	 */
	public String delForm() throws Exception {
		if(!ids.endsWith("0")) {
			return SUCCESS;
		}
		ipInfoService.removeOnlyInfo(ids);
		return SUCCESS;
	}
	public Page getPage() {
		return page;
	}

	
	public void setIpInfoService(IpService ipInfoService) {
		this.ipInfoService = ipInfoService;
	}


	public void setOtherService(OtherService otherService) {
		this.otherService = otherService;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getCountry() {
		return country;
	}

	public void setCountry(String country) {
		this.country = country;
	}

	public String getRegion() {
		return region;
	}

	public void setRegion(String region) {
		this.region = region;
	}

	public String getCity() {
		return city;
	}

	public void setCity(String city) {
		this.city = city;
	}

	public int getPageNo() {
		return pageNo;
	}

	public void setPageNo(int pageNo) {
		this.pageNo = pageNo;
	}

	public boolean isFlag() {
		return flag;
	}

	public void setFlag(boolean flag) {
		this.flag = flag;
	}

	public int getPageSize() {
		return pageSize;
	}

	public String getState() {
		return state;
	}

	public void setState(String state) {
		this.state = state;
	}
	public String getIds() {
		return ids;
	}
	public void setIds(String ids) {
		this.ids = ids;
	}
	
	public String modifyPrice(){
		try {
			OnlyIpInfo onlyIp = ipInfoService.findOnlyById(id);
			onlyIp.setPrice(price);
			ipInfoService.updateOnlyIp(onlyIp);
			flag=true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "modify";
	}
	public void setId(int id) {
		this.id = id;
	}
	public void setPrice(double price) {
		this.price = price;
	}
	public void setRepeat(String repeat) {
		this.repeat = repeat;
	}
	public String getRepeat() {
		return repeat;
	}
	

}
